<template>
	<view>
		<uni-nav-bar title="通知" background-color="#FE6B39" color="#FFF" left-icon="back" @clickLeft="$tab.back()"
			:border="false" :status-bar="true" :fixed="true"></uni-nav-bar>

		<view class="px-20">
			<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :fixed="false">
				<view class="flex flex-col items-center mt-32" v-for="(item,index) in list" :key="item.noticeId" @click="goDetal(item.noticeId)">
					<view class="time text-center text-24 text-FFF">
						{{item.createTime}}
					</view>

					<view class="bg-FFF p-16 mt-32 w-full round-8">
						<view class="flex items-center justify-between">
							<view class="flex items-center">
								<image
									src="https://file.fulewanjia.com/fulewanjia/profile/appImages/icon_xitongxiaoxi.png"
									class="image-44" mode=""></image>
								<view class="text-32 font-700 ml-12">
									{{item.noticeType == 1 ? '系统通知' : '系统公告'}}
								</view>
							</view>
							<view class="flex items-center">
								<view class="text-gray text-28">
									查看详情
								</view>
								<image
									src="https://file.fulewanjia.com/fulewanjia/profile/appImg/index/icon_chakanxiangqing@2x.png"
									mode="" class="image-40"></image>
							</view>

						</view>
						<view class="my-24">
							<u-line color="#F4F4F4"></u-line>
						</view>
						<view class="text-32">
							{{item.noticeTitle}}
						</view>
					</view>
				</view>
			</s-pull-scroll>
			
			<IsShow :isShow="list.length == 0" isShowImg="https://file.fulewanjia.com/fulewanjia/profile/appImg/index/image_zanwutongzhi.png" isShowText="暂无通知"></IsShow>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			};
		},
		onLoad() {
			this.refresh()
		},
		methods: {
			goDetal(id){
				this.$tab.nav(`/pages/index/notice/detail?id=${id}`)
			},
			refresh() {
				this.$nextTick(() => {
					this.$refs.pullScroll.refresh();
				});
			},
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			loadData(pullScroll) {
				setTimeout(async () => {
					if (pullScroll.page == 1) {
						this.list = [];
					}

					const res = await this.$Api.index.getNotice()

					this.list = this.list.concat(res.rows || []);


					if (this.list.length >= res.total) {
						pullScroll.finish();
					} else {
						pullScroll.success();
					}
				}, 500);
			}
		}
	}
</script>

<style>
	page {
		background-color: #F8F8F8;
	}
</style>

<style lang="scss">
	.time {
		width: 260rpx;
		height: 52rpx;
		background: rgba(0, 0, 0, .1);
		border-radius: 100rpx;
		line-height: 52rpx;
	}
</style>